package com.example.job_backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.job_backend.mapper.ScoreMapper;
import com.example.job_backend.model.Query.ScoreQuery;
import com.example.job_backend.model.Score;
import com.example.job_backend.service.ScoreService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ScoreServiceImpl extends ServiceImpl<ScoreMapper, Score> implements ScoreService {

    @Resource
    private ScoreMapper scoreMapper;
    @Override
    public PageInfo<Score> getScoreByPage(ScoreQuery query) {
        PageHelper.startPage(query.getPage(), query.getPageSize());
        QueryWrapper<Score> wrapper = new QueryWrapper<>();
        wrapper.like("student_name", query.getStudentName())
                .like("course_name", query.getCourseName());
        List<Score> list = scoreMapper.selectList(wrapper);
        PageInfo<Score> page = new PageInfo<>(list);
        return page;
    }

    @Override
    public List<Score> getScoreByUsername(String username) {
        QueryWrapper<Score> wrapper=new QueryWrapper<>();
        wrapper.eq("student_id",username);
        return scoreMapper.selectList(wrapper);
    }
}
